<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        width: 100px;
        height: 100px;
        border: 1px solid red;
      }
      .new {
        background-color: rosybrown;
      }
    </style>
  </head>
  <body>
    <div class="box" id="put">112233</div>
    <script>
      var boxEle = document.querySelector(".box");
      //   console.log(boxEle.className);获取类名
      document.onclick = function () {
        // boxEle.className = "new";修改类名 不要覆盖原来的类名
        boxEle.className += " new";
      };
      var boxEle = document.getElementById("put");
      //   console.log(boxEle.id);获取id名
      //   boxEle.id = "love";修改id名
    </script>
  </body>
</html>
